**********************************************************
* Information, Candidate Selection, and the Quality of Representation: Evidence from Nepal
* Replication .do File for Main Paper Results Tables
**********************************************************
cls
clear 

version 15.1


* install commands
ssc install reghdfe
ssc install lincom
ssc install estout
ssc install orth_out

* Set Working Directory
cd "~/Dropbox/nepal_localgovt/analysis/"
global repl_dir "jop/replication archive"
global rinf_dir "${repl_dir}"
do "${rinf_dir}/rinf_program.do" 
cd "${repl_dir}"
* set number  of iterations for exact p-values
local num_iter = 5000

* load dataset
use nepal_final_cleaned.dta, clear



* Table 1: Correlates of Candidate Nominations
* col 1
areg first_rank first_rank_survey, absorb(seattype) cluster(seatid)
* col 2
areg first_rank first_rank_survey age female, absorb(seattype) cluster(seatid)
* col 3
areg first_rank first_rank_survey age female   partyjoin_years committee_member relatives_elections relatives_politics, absorb(seattype) cluster(seatid)
* col 4
areg first_rank first_rank_survey age female   business lincome  highestlevelofeducation , absorb(seattype) cluster(seatid)
* col 5
areg first_rank first_rank_survey age female partyjoin_years committee_member relatives_elections relatives_politics  business lincome  highestlevelofeducation , absorb(seattype) cluster(seatid)




* Table 3: Polling information changes party leader’s candidate selection
* col 1
rinf, esttype(0) dv(ticket_p_notranked_first) iter(`num_iter') treats(treat_elect treat_loyal treat_comp) numtreat(3) absorb(" ") cluster(seatid) lr(2) lr1(" ")
reg ticket_p_notranked_first treat_elect treat_loyal treat_comp, r cluster(seatid)
* col 2
rinf, esttype(0) dv(ticket_p_notranked_first) iter(`num_iter') treats(treat_elect treat_loyal treat_comp i.block) numtreat(3) absorb(" ") cluster(seatid) lr(2) lr1(" ")
reg ticket_p_notranked_first treat_elect treat_loyal treat_comp , r cluster(seatid)
* col 3
rinf, esttype(0) dv(ticket_p_notranked_first) iter(`num_iter') treats(treat_elect treat_loyal treat_comp i.seattype_no) numtreat(3) absorb(" ") cluster(seatid) lr(2) lr1(" ")
reg ticket_p_notranked_first treat_elect treat_loyal treat_comp  i.seattype_no, r cluster(seatid)
* col 4
rinf, esttype(0) dv(ticket_p_notranked_first) iter(`num_iter') treats(treat_elect treat_loyal treat_comp  i.block i.seattype_no) numtreat(3) absorb(" ") cluster(seatid) lr(2) lr1(" ")
reg ticket_p_notranked_first treat_elect treat_loyal treat_comp  i.block i.seattype_no, r cluster(seatid)



* Table 4: Polling Information Improves the Party’s Vote Share
* col 1
rinf, esttype(0) dv(vshare) iter(`num_iter') treats(treat_elect treat_loyal treat_comp ) numtreat(3) absorb(" ") cluster(" ") lr(2) lr1(" ")
reg vshare treat_elect treat_loyal treat_comp ,  r
* col 2
rinf, esttype(1) dv(vshare) iter(`num_iter') treats(treat_elect treat_loyal treat_comp ) numtreat(3) absorb(block) cluster(" ") lr(2) lr1(" ")
reghdfe vshare treat_elect treat_loyal treat_comp ,  absorb(block) vce(robust)
* col 3
rinf, esttype(1) dv(vshare) iter(`num_iter') treats(treat_elect treat_loyal treat_comp ) numtreat(3) absorb(seattype_no) cluster(" ") lr(2) lr1(" ")
reghdfe vshare treat_elect treat_loyal treat_comp ,  absorb(seattype_no) vce(robust)
* col 4
rinf, esttype(1) dv(vshare) iter(`num_iter') treats(treat_elect treat_loyal treat_comp ) numtreat(3) absorb(block seattype_no) cluster(" ") lr(2) lr1(" ")
reghdfe vshare treat_elect treat_loyal treat_comp ,  absorb(block seattype_no) vce(robust)



* Table 6: Heterogeneous Treatment Effects by Leader-Voter Deviation
* col 1
rinf, esttype(0) dv(ticket_p_notranked_first) iter(`num_iter') treats(treat_elect treat_loyal treat_comp i.seattype_no i.block) numtreat(5) absorb(" ") cluster(seatid) lr(2) lr1(" ")
reg ticket_p_notranked_first treat_elect treat_loyal treat_comp i.seattype_no i.block, r cluster(seatid)

* col 2
* Panel A
rinf, esttype(3) dv(ticket_p_notranked_first) iter(`num_iter') treats(treat_elect_climb_neg treat_elect_climb_noch treat_elect_climb_pos climb_sign_id1 climb_sign_id2 climb_sign_id3 treat_loyal treat_comp i.block i.seattype_no) numtreat(10) absorb(" ") cluster(seatid) lr(2) lr1(" ")
reg ticket_p_notranked_first treat_elect_climb_neg treat_elect_climb_noch treat_elect_climb_pos climb_sign_id1 climb_sign_id2 climb_sign_id3 treat_loyal treat_comp i.block i.seattype_no, nocons r cluster(seatid)

* Panel B - linear restrictions
local mytesta treat_elect_climb_pos-treat_elect_climb_noch
rinf, esttype(3) dv(ticket_p_notranked_first) iter(`num_iter') treats(treat_elect_climb_neg treat_elect_climb_noch treat_elect_climb_pos climb_sign_id1 climb_sign_id2 climb_sign_id3 treat_loyal treat_comp i.block i.seattype_no) numtreat(1) absorb(" ") cluster(seatid) lr(1) lr1(`mytesta')
reg ticket_p_notranked_first treat_elect_climb_neg treat_elect_climb_noch treat_elect_climb_pos climb_sign_id1 climb_sign_id2 climb_sign_id3 treat_loyal treat_comp i.block i.seattype_no, nocons r cluster(seatid)
lincom `mytesta'
























